use "C:\Countries",replace
keep country iso3
save "C:\Isos",replace
use "C:\Future Years"
keep year
save "C:\Years",replace
cross using "C:\ISOs"
gen mark=1
sort iso3 year
save "C:\z0",replace

use "C:\Real IMF GDPPC PPP"
replace iso3="ZAR" if iso3=="COD"
replace iso3="ROM" if iso3=="ROU"
gen rgdppc=rimfgpcppp
gen lrgdppc=log(rgdppc)
gen icountry=country
drop country
sort iso3 year
save "C:\z1",replace

use "C:\z0"
merge iso3 year using "C:\z1"
save "C:\z3",replace
drop _merge
sort country year
keep country iso3 year rgdppc lrgdppc

drop if year<1980
* keep if country=="Cambodia" | country=="China" | country=="Indonesia" | country=="Lao PDR" | country=="Malaysia" | country=="Myanmar" | country=="Thailand" | country=="Vietnam"
replace rgdppc=0 if rgdppc==.
sort country year
merge country using "C:\Country Multipliers"
drop _merge

***
replace crossinc=15000
***

sort country year
save "C:\z2",replace

keep if year==2010
replace rgdppc=. if rgdppc==0
gen inc2010=rgdppc
keep country inc2010
sort country
save "C:\z2010",replace

use "C:\z2",replace
replace rgdppc=. if rgdppc==0
keep if year==2000
gen inc2000=rgdppc
keep country inc2000
sort country
save "C:\z2000",replace

use "C:\z2",replace
replace rgdppc=. if rgdppc==0
keep if year==1990
gen inc1990=rgdppc
keep country inc1990
sort country
save "C:\z1990",replace

use "C:\z2",replace
replace rgdppc=. if rgdppc==0
keep if year==1980
gen inc1980=rgdppc
keep country inc1980
sort country
save "C:\z1980",replace


use "C:\z2"
xi: reg lrgdppc i.country*year if year>2000 & year<2011
predict pg
gen prgdppc=exp(pg)
gen rgdppc10=rgdppc
replace rgdppc10=prgdppc if year>2010
bysort country: gen inc1=rgdppc10[42]
bysort country: gen compinc10=rgdppc10[52]
bysort country: gen testinc10=rgdppc10[62]

sort country year
gen intvl=10
by country, sort: egen date10 = min(cond(rgdppc10>=crossinc, year, .))
replace date10=2100 if date10==.
egen tc=tag(country)
keep if tc==1

gen grate10=100*((compinc10/inc1)^(1/intvl)-1)
gen trate10=100*((testinc10/compinc10)^(1/intvl)-1)

sort country
save "C:\z10",replace


use "C:\z2"

xi: reg lrgdppc i.country*year if year>1990 & year<2011
predict pg
gen prgdppc=exp(pg)
gen rgdppc20=rgdppc
replace rgdppc20=prgdppc if year>2010
bysort country: gen inc1=rgdppc20[42]
bysort country: gen compinc20=rgdppc20[52]
bysort country: gen testinc20=rgdppc20[62]

sort country year

gen intvl=10
by country, sort: egen date20 = min(cond(rgdppc20>=crossinc, year, .))
replace date20=2100 if date20==.
egen tc=tag(country)
keep if tc==1

gen grate20=100*((compinc20/inc1)^(1/intvl)-1)
gen trate20=100*((testinc20/compinc20)^(1/intvl)-1)

sort country
save "C:\z20",replace

use "C:\z2"

xi: reg lrgdppc i.country*year if year>1980 & year<2011
predict pg
gen prgdppc=exp(pg)
gen rgdppc30=rgdppc
replace rgdppc30=prgdppc if year>2010
bysort country: gen inc1=rgdppc30[42]
bysort country: gen compinc30=rgdppc30[52]
bysort country: gen testinc30=rgdppc30[62]

sort country year
save "C:\z2",replace

gen intvl=10
by country, sort: egen date30 = min(cond(rgdppc30>=crossinc, year, .))
replace date30=2100 if date30==.
egen tc=tag(country)
keep if tc==1

gen grate30=100*((compinc30/inc1)^(1/intvl)-1)
gen trate30=100*((testinc30/compinc30)^(1/intvl)-1)

drop pg prgdppc 
sort country
save "C:\z30",replace
merge country using "C:\z20"
drop _merge
sort country
merge country using "C:\z10"
drop _merge
sort country
merge country using "C:\z1980"
drop _merge
sort country
merge country using "C:\z1990"
drop _merge
sort country
merge country using "C:\z2000"
drop _merge
sort country
merge country using "C:\z2010"
drop _merge
sort country

replace country="Laos" if country=="Lao PDR" 
replace mav=1 if mav==.
drop if country==""
format inc* %7.0f grate* %7.2f rgdppc* %7.0f
keep country iso3 mav inc1980 inc1990 inc2000 inc2010 grate10 grate20 grate30 trate10 trate20 trate30 date10 date20 date30 rgdppc10 rgdppc20 rgdppc30 
sort iso3
save "C:\Transition Years",replace

*** Table 2

outsheet country date* grate* inc* using "C:\Transition Year Data",replace




  

